public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length-1;
        int n = 0;
        int[] result = new int[height.length];

        while (left < right) {
            if (height[left]>height[right]) {
                result[n++] = sum(height,left,right);
                right--;
            } else {
                result[n++] = sum(height,left,right);
                left++;
            }
        }
        int max = result[0];
        for (int i = 0;i < result.length;i++) {
            if (result[i]>max) {
                max = result[i];
            }
        }
        return max;
    }

    private int sum(int[] height,int left,int right) {
        if (height[left]>height[right]) {
            return (right - left)*height[right];
        } else {
            return (right - left)*height[left];
        }
    }
}